package baiqitun.stupro.api.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

/**
 * @author kedaji
 */
@EnableSwagger2
@Configuration
public class SwaggerConfig {
    @Value("${swagger.enable}")
    private Boolean enable;

    @Bean
    public Docket docket(){
        return new Docket(DocumentationType.SWAGGER_2).enable(enable)
                .apiInfo(apiInfo())
                .select()
                //指定要扫描的包
                .apis(RequestHandlerSelectors.basePackage("baiqitun.stupro"))
                .build();
    }

    private ApiInfo apiInfo(){
        return new ApiInfo("一生一品项目管理系统前后端接口文档",
                "所有API都会实时更新到此文档中",
                "1.0.0",
                "https://gitee.com/baiqitun",
                new Contact("kedaji", "https://blog.csdn.net/kedaji","kedaji@yeah.net"),
                "木兰宽松许可证, 第1版",
                "https://license.coscl.org.cn/",
                new ArrayList());
    }
}
